package com.woyowodaows.popupwind;

import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.woyowodaows.R;
import com.woyowodaows.base.BasePopupwindow;

import butterknife.OnClick;

/**
 * Created by Administrator on 2017/8/10.
 */

public class ChoosePicWindow extends BasePopupwindow implements View.OnClickListener{

    public  TextView takePhoto;//拍照

    public  TextView choosePhoto;//图片

    public TextView cancel;//取消按钮

    public RelativeLayout rlPopWindow;


    private OnItemClickListener onItemClickListener;

    public String isShow;//是否显示

    public ChoosePicWindow(Context mContext, View views, String isShow) {
        super(mContext, views);
        this.isShow=isShow;
    }

    @OnClick(R.id.tv_cancel_choose)
    public void onCancel(){
        hidePopupWindow();

    }
    public void setOnItemClickListener(OnItemClickListener itemClickListener ){
        this.onItemClickListener = itemClickListener;
    }

    @Override
    public void initView(View layoutViews) {

        takePhoto=(TextView) layoutViews.findViewById(R.id.tv_take_photo);//拍照

        choosePhoto=(TextView) layoutViews.findViewById(R.id.tv_choose_photo);//图片

        cancel=(TextView) layoutViews.findViewById(R.id.tv_cancel_choose);//取消按钮

        rlPopWindow=(RelativeLayout) layoutViews.findViewById(R.id.rl_pop_window);
        takePhoto.setOnClickListener(this);
        choosePhoto.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }
    public   void hideShowView(String titleName){

        takePhoto.setVisibility(View.GONE);
        choosePhoto.setText(titleName);

    }


        @Override
    public int getLayoutId() {
        return R.layout.pop_take_photo;
    }

    @Override
    public View animationView() {
        return rlPopWindow;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_take_photo:
                if (onItemClickListener != null){
                    onItemClickListener.onTake();
                }
                break;
            case R.id.tv_choose_photo:
                if (onItemClickListener != null){
                    onItemClickListener.onChoose();
                }
                break;
            case  R.id.tv_cancel_choose:
                hidePopupWindow();
                break;
        }
    }

    public interface OnItemClickListener{
        void onTake();
        void onChoose();

    }
}
